def check_close_ais(data_input, now_timestamp):
    data_output = []
    for data in data_input:
        latest_data = data['trackData'].pop()
        latest_timestamp = latest_data['timestamp']
        if now_timestamp - latest_timestamp >= 2000:
            data_output.append({
                'trackId': data['trackId'],
                'actionKey': 'closeAdsb',
                'startTime': latest_timestamp,
                'endTime': 0
            })
    return data_output

def check_speed_high(data_input, now_timestamp):
    data_output = []
    output_dict = {}
    for data in data_input:
        for data_sub in data['trackData']:
            if data_sub['speed'] > 10:
                track_id = data['trackId']
                if output_dict.get(track_id, None) is None:
                    output_dict[track_id] = {
                        'trackId': track_id,
                        'actionKey': 'speedHigh',
                        'startTime': data_sub['timestamp'],
                        'endTime': 0
                    }
                output_dict[track_id]['endTime'] = data_sub['timestamp']
    for data in output_dict.values():
        data_output.append(data)
    return data_output

if __name__ == '__main__':
    # 此处可自行调试
    pass

